package j20251012;

import java.util.Scanner;

public class Demo2 {

    static class Counter{
        public volatile int flag=0;
    }
    public static void main(String[] args) throws InterruptedException {
        Counter c=new Counter();
        Thread t1=new Thread(()->{
            while(c.flag ==0){

            }
        });
        Thread t2=new Thread(()->{
            Scanner sc=new Scanner(System.in);
            System.out.println("请输入一个不为0的值");
            c.flag=sc.nextInt();
        });
        t1.start();
        t2.start();
        t1.join();
        t2.join();
        System.out.println(c);
    }
}
